package com.ng.desktop.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.IndexColumn;

@Entity
@Table(name = "TH_INTERCAMBIO")
public class Intercambio {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", nullable = false)
	private Long id;
	
	@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST})
	@ForeignKey(name = "FK_INTERCAMBIO", inverseName = "FK_ALIMENTO")
	@JoinTable(name = "TH_INTERCAMBIO_ALIMENTO", joinColumns = @JoinColumn(name = "ID_INTERCAMBIO"), inverseJoinColumns = @JoinColumn(name = "ID_ALIMENTO"))
	@IndexColumn(name = "IDX_INTERCAMBIO_ALIMENTO")
	private Set<Alimento> alimentos;

	public final Long getId() {
		return id;
	}

	public final void setId(Long id) {
		this.id = id;
	}

	public final Set<Alimento> getAlimentos() {
		return alimentos;
	}

	public final void setAlimentos(Set<Alimento> alimentos) {
		this.alimentos = alimentos;
	}
	
}
